package com.luom.fsp.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.luom.fsp.model.dto.order.*;
import com.luom.fsp.model.entity.Order;
import com.luom.fsp.model.vo.OrderPriceVO;
import com.luom.fsp.model.vo.OrderVO;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 订单服务
 *
*/
public interface OrderService extends IService<Order> {

    /**
     * 校验数据
     *
     * @param order
     * @param add 对创建的数据进行校验
     */
    void validOrder(Order order, boolean add);

    /**
     * 获取查询条件
     *
     * @param orderQueryRequest
     * @return
     */
    QueryWrapper<Order> getQueryWrapper(OrderQueryRequest orderQueryRequest);
    
    /**
     * 获取订单封装
     *
     * @param order
     * @param request
     * @return
     */
    OrderVO getOrderVO(Order order, HttpServletRequest request);

    /**
     * 分页获取订单封装
     *
     * @param orderPage
     * @param request
     * @return
     */
    Page<OrderVO> getOrderVOPage(Page<Order> orderPage, HttpServletRequest request);

    /**
     * 新增订单
     * @param orderAddRequest
     * @param request
     * @return
     */
    long addOrder(OrderAddRequest orderAddRequest, HttpServletRequest request);

    /**
     * 订单支付
     * @param orderOperationRequest
     * @param request
     * @return
     */
    Boolean payOrder(OrderOperationRequest orderOperationRequest, HttpServletRequest request);

    /**
     * 订单确认收货
     */
    Boolean confirmReceipt(OrderOperationRequest orderOperationRequest, HttpServletRequest request);

    /**
     * 订单取消
     * @param orderOperationRequest
     * @param request
     * @return
     */
    Boolean cancelOrder(OrderOperationRequest orderOperationRequest, HttpServletRequest request);

    /**
     * 退款
     * @param orderOperationRequest
     * @param request
     * @return
     */
    Boolean refundOrder(OrderOperationRequest orderOperationRequest, HttpServletRequest request);

    /**
     * 查询订单
     * @param orderAllQueryRequest
     * @param request
     * @return
     */
    Page<OrderVO> listOrderVOByPage(OrderAllQueryRequest orderAllQueryRequest, HttpServletRequest request);

    /**
     * 发货
     * @param orderOperationRequest
     * @param request
     * @return
     */
    Boolean deliverOrder(OrderOperationRequest orderOperationRequest, HttpServletRequest request);

    /**
     * 批量新增订单
     * @param orderAddBatchRequest
     * @param request
     * @return
     */
    Boolean addOrderBatch(OrderAddBatchRequest orderAddBatchRequest, HttpServletRequest request);

    /**
     * 更新redis中销量
     * @param order
     */
    void updateSalesInRedis(Order order);

    /**
     * 计算价价格
     * @param couponId
     * @param money
     * @return
     */
    OrderPriceVO getOrderPrice(Long couponId, Integer money);
}
